home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
4.1
/
Set-collect.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
1KB
|
34 lines
" NAME Set-collect
AUTHOR miw@cs.man.ac.uk (Mario Wolczko)
FUNCTION Fixes a bug in Set>collect:
ST-VERSION 4.1
PREREQUISITES
CONFLICTS Set>collect:
DISTRIBUTION world
VERSION 1
DATE 18 Sep 1991
SUMMARY
The default definition of Set>collect: doesn't use species, but
creates a new Set, regardless of whether it is actually used in Set or a
subclass. I think this is a bug -- ParcPlace think it's a feature!!"
'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 26 November 1992 at 3:07:42 pm'!
!Set methodsFor: 'enumerating'!
collect: aBlock
"Evaluate aBlock with each of the values of the receiver as the
argument. Collect the resulting values into a Set that is like
the receiver. Answer the new Set."
"Override the general method, so that we make a big enough set and avoid growing. "
"Set changed to self species, MIW, 26 Nov 1992"
| newSet size |
tally = 0 ifTrue: [^self species new: 2].
newSet := self species new: (size := self basicSize).
1 to: size do: [:index | | element |
(element := self basicAt: index) == nil ifFalse:
[newSet add: (aBlock value: element)]].
^newSet! !